package com.itzhoun.utils;

import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author 周楠
 * @Date 2022/07/26/下午 10:09
 */
@Slf4j
public class NetWorkIPUtils {

    public static InetAddress getIPAddress() {
        try {
            InetAddress localHost = InetAddress.getLocalHost();
            log.info("localhost: " + localHost);
            log.info("getHostAddress:  " + localHost.getHostAddress());
            log.info("getHostName:  " + localHost.getHostName());
            return localHost;
        }catch (UnknownHostException e){
            log.error("获取");
        }
        return null;
    }

    public static void main(String[] args) throws UnknownHostException {
        InetAddress ipAddress = getIPAddress();
    }

}
